<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联后台管理系统</title>
  <meta name="description" content="商之联后台管理系统">
  <meta name="keywords" content="form">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SUPPLIER_ADMIN_IMAGE')}favicon.png">
  <link rel="apple-touch-icon-precomposed" href="{:C('SUPPLIER_ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}admin.css">
  <link href="{:C('SUPPLIER_ADMIN_JS')}themes/default/css/ueditor.css" type="text/css" rel="stylesheet">
  <link href="{:C('SUPPLIER_ADMIN_JS')}themes/default/css/ueditor.css" type="text/css" rel="stylesheet">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
<!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->

<!-- content start -->
<div class="admin-content">
 
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商品管理</strong> / <small>编辑商品</small></div>
  </div>
 <form action="{:U('Item/updateItem')}" method="post" enctype="multipart/form-data">
  
  <div class="am-tabs am-margin" data-am-tabs="{noSwipe: 1}" >
    <ul class="am-tabs-nav am-nav am-nav-tabs">
      <li class="am-active"><a href="#tab1">基本信息</a></li>
      <li><a href="#tab2" >商品详情</a></li>
      <li><a href="#tab3">商品属性</a></li>
    </ul>

    <div class="am-tabs-bd">
    <!-- 商品基本信息-->
      <div class="am-tab-panel am-fade am-in am-active" id="tab1">
        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品类目</div>
          <div class="am-u-sm-10">
            <select name='itemtype' onchange="reload(this.options[this.options.selectedIndex].value)" disabled="disabled">
            <option value=0>请选择</option>
            <foreach name="typearr" item="types" key="key">
            
              <option value="{$key}" <?php  if($iteminfo['typeid']==$key) echo 'selected=1'; ?> > 
              <?php  echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',$types['level']);?> {$types['typename']}
              </option>
              </foreach>
            </select>
          </div>
        </div>
      
      <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品名称</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="itemname" value="{$iteminfo['itemname']}">
            </div>
          </div>
        </div>
    
    <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品型号</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="bn" value="{$iteminfo['bn']}">
            </div>
          </div>
        </div>
      <if condition="$brands neq '' ">
         <div  class="am-g am-margin-top">
        <div class="am-u-sm-2 am-text-right"> 
        品牌
        </div>
          <div class="am-u-sm-10">
            <select name="brand">
            <option>请选择</option>
            <foreach name="brands" item="brand" key="key"> 
              <option value="{$key}"  <if condition="$iteminfo['brandid'] eq $key"> selected=1</if>  >{$brand}</option>
                </foreach>
            </select>
          </div>    
      </div>
      </if>
    <!-- 属性end-->
      <div class='speccontain'>
       <hr/>
      <foreach name="specs" item="spec" key="key">
          <div class='am-g am-margin-top'>
            <div class='am-u-sm-2 am-text-right specname'>{$spec.name}</div>
            <div class='am-u-sm-10 spec_{$spec.specid}'>
          <foreach name="spec.specval" item="value" >
              <span>
                <input type='checkbox' name="spec[{$value.specid}][{$value.specvalid}]" value="{$value.name}" class="{$value.specvalid}" <if condition="$value['checked'] eq true">checked=1 </if> >
              <label for="{$value.name}" >{$value.name} </label></span>
              </foreach>
            </div>
          </div>
      </foreach>
      <!--选择规格end -->
      <!--添加货品-->
        <div class='am-g am-margin-top'>
          <div class='am-u-sm-12'>
            <table class="am-table am-table-bordered am-table-striped am-table-compact" id='spectable'>
            <thead>
                <tr>
                    
                    <th>颜色 </th>
                    <th>零售价</th>
                    <th>供货价</th>
                    <th>库存</th>
                </tr>
            </thead>
            <foreach name="products" item="product" key='k'>
              <tr>
              <foreach name='product' item="value" key='k'>
              <td> <input name="p_color[{$k}]" value="{$value['color']}"> </td>
              <td> <input name="p_price[{$k}]" value="{$value['price']}"> </td>
              <td> <input name="p_supprice[{$k}]" value="{$value['supprice']}"> </td>
              <td><input  name="p_inventory[{$k}]" value="{$value['inventory']}"></td>
              </foreach>
              </tr>
            </foreach>
            <tbody> 
            </tbody>
            </table>
            <p>
                <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick=appendrow();return false;>
                    <span class="am-icon-pencil-square-o"></span>添加更多</button>
                        </p>
          </div>
          
        </div>
      <!--添加货品 -->
        <hr/>
    </div>
        <!--开启规格end-->
  

        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品价格</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="price"  value="{$iteminfo['price']}">(开启规格后，价格必须在货品价格之间)
            </div>
          </div>
        </div>

        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">供货价</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="supperprice" value="{$iteminfo['supperprice']}" >
            </div>
          </div>
        </div>

        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">供应商</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
               <select name="supptypeid">
               <option value="0">请选择供应商</option>

                <foreach name="suppliers" item="value" key="key">
                
                 <if condition="$iteminfo['supptypeid'] eq $value ">selected </if> <option value={$key}> {$value} </option> 
                </foreach>
            
          </select>
            </div>
          </div>
        </div>

            <!--购买区域-->
            <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">购买区</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
               <select name="areatype">

                
                
                 <if condition="$areatype eq 1 ">
                 <option value="1" selected="selected">现货区</option>
                  <option value="0" >请选择</option>
                <option value="3" >店长推荐区</option> 
                 <elseif condition="$areatype eq 3"/> 
                 <option value="3" selected="selected">店长推荐区</option>
                 <option value="0" >请选择</option>
                <option value="1" >现货区</option> 
                 <else/>
                 <option value="0" selected="selected">请选择</option>
                 <option value="3" >店长推荐区</option>
                 <option value="1" >现货区</option>
                 </if>
               
            
          </select>
            </div>
          </div>
        </div>
        <!--购买区end-->


         <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">商品库存</div>
          <div class="am-u-sm-10">
            <div class="am-btn-group" data-am-button>  
                <input type="text" name="inventory" value="{$iteminfo['inventory']}">(开启规格后，库存必须为所有货品库存之和)
            </div>
          </div>
        </div>

    
        <div class="am-g am-margin-top">
          <div class="am-u-sm-2 am-text-right">列表图片</div>
          <div class="am-u-sm-10">
           <div class="am-form-group">
          <input type="file" id="doc-ipt-file-1" name='listimg'>
          <p class="am-form-help">请选择要上传的文件...(像素要求557*557)</p>
          <div><if condition="$iteminfo['itemimg'] neq '' ">
          <img src="{:C('SITENAME')}{$iteminfo['itemimg']}">
          </if>
          </div>
       </div>
          </div>
        </div>
      </div>
  <!-- 商品基本信息end-->
    <!-- 商品详情-->
      <div class="am-tab-panel am-fade" id="tab2">
       <script type="text/plain" id="container" style="width:1000px;height:540px;">
          {$detail}
       </script>
      </div>
  <!-- 商品详情end -->
  <!--商品属性 start-->
    <div class="am-tab-panel am-fade" id="tab3">
          <!--属性start-->
    <foreach name="typeproperty" item="propers" key="key" > 
      <div  class="am-g am-margin-top">
        <div class="am-u-sm-2 am-text-right">
          {$propers['propertyname']}
        </div>
          <div class="am-u-sm-10">
            <select name="proper[{$key}]">
            <option>请选择</option>
            <foreach name="propers.select" item="value" key="k">
              
              <option value="{$k}"
           <if condition="$value['selected'] eq true "> selected=1</if>  >{$value['propertyvalue']}</option>
            </foreach>
            </select>
          </div>    
      </div>
      </foreach>
    </div>
  <!--商品属性 end-->

    </div>
  </div>

  <div class="am-margin">
    <button type="button" class="am-btn am-btn-primary am-btn-xs"  onclick="this.form.submit()">提交保存</button>
    <button type="button" class="am-btn am-btn-primary am-btn-xs">重置</button>
  </div>
  <input type='hidden' value="{$iteminfo['itemid']} " name="itemid">
  <input type='hidden' value="{$iteminfo['typeid']} " name="typeid">

  </form>
</div>
<!-- content end -->

</div>

<!-- 回到顶部 start-->
  <div class="amz-toolbar" id="amz-toolbar" style="right:99.5px;position: fixed;z-index: 999;bottom: 10px;">
<a href="#top" title="回到顶部" class="am-icon-btn am-icon-arrow-up am-active" id="amz-go-top"></a>
 </div>
<!-- 回到顶部end -->


<script type="text/javascript"charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>

<script type="text/javascript"charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}jquery.min.js"></script>
<script type="text/javascript"charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="{:C('SUPPLIER_ADMIN_JS')}ueditor.all.js"></script>
<script type="text/javascript" src="{:C('SUPPLIER_ADMIN_JS')}lang/zh-cn/zh-cn.js"></script>
<link href="http://ueditor.baidu.com/ueditor/themes/default/css/ueditor.css" type="text/css" rel="stylesheet">

<script type="text/javascript">
$(document).ready(function(){
 // $('.tab2').tabs({noSwipe: 1});
});

 function reload(x){
  var typeid=x;
    window.location.href="{:U(Item/addItem)}"+"?typeid="+typeid;
 }
</script>
<script type="text/javascript">
function appendrow()
{
  event.preventDefault();
   var str='<tr class="row"><td><input type="text" name="n_color[]"/><td><input type="text" name="n_price[]"/></td><td><input type="text" name="n_supprice[]"/></td><td><input type="text" name="n_inventory[]"/><button class="am-btn am-btn-default am-btn-xs am-text-danger" onclick=delproduct(this.parentNode)><span class="am-icon-trash-o"></span> 取消</button></td></tr>';
   $('#spectable').append(str);
} 
//删除product
function   delproduct(obj){
  event.preventDefault();
   var trnode=obj.parentNode;
   if(trnode) trnode.parentNode.removeChild(trnode);
}

</script>
<!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
    </script>
</body>
</html>
